<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>玩转spring boot——简单登录认证</title>
    <script src="//cdn.bootcss.com/angular.js/1.5.6/angular.min.js"></script>
    <script type="text/javascript">
        /*<![CDATA[*/
        var app = angular.module('app', []);
        app.controller('MainController', function ($rootScope, $scope, $http) {
            $scope.message = '';
            $scope.account = '';
            $scope.password = '';

            //登录
            $scope.login = function () {
                $scope.message = '';
                $http(
                    {
                        url: '/sys/loginPost',
//                        url: 'http://www.baidu.com/sys/loginPost',
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/x-www-form-urlencoded'
                        },
                        data: 'account=' + $scope.account + '&password='
                        + $scope.password
                    }).success(function (r) {
                    if (!r.success) {
                        $scope.message = r.message;
                        return;
                    }
                    window.location.href = '/sys/';
                });
            }

        });
        /*]]>*/
    </script>
</head>
<body ng-app="app" ng-controller="MainController">
<h1>玩转spring boot——简单登录认证</h1>
<h4>
    <a href="http://www.cnblogs.com/GoodHelper/">from 刘冬的博客</a>
</h4>

<table cellspacing="1" style="background-color: #a0c6e5">
    <tr>
        <td>账号：</td>
        <td><input ng-model="account"/></td>
    </tr>
    <tr>
        <td>密码：</td>
        <td><input type="password" ng-model="password"/></td>
    </tr>
</table>
<input type="button" value="登录" ng-click="login()"/>
<br/>
<font color="red" ng-show="message">{{message}}</font>
<br/>
<a href="http://www.cnblogs.com/GoodHelper/">点击访问原版博客(www.cnblogs.com/GoodHelper)</a>
</body>
</html>